home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / inet / netinet / in.h
C/C++ Source or Header  |  1994-02-06  |  7KB  |  195 lines

  1. /* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. GNU General Public License for more details.
  13.  
  14. You should have received a copy of the GNU General Public License
  15. along with the GNU C Library; see the file COPYING.  If not, write to
  16. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  17.  
  18. #ifndef    _NETINET_IN_H
  19.  
  20. #define    _NETINET_IN_H    1
  21. #include <features.h>
  22.  
  23. #include <sys/socket.h>
  24.  
  25.  
  26. /* Standard well-defined IP protocols.  */
  27. enum
  28.   {
  29.     IPPROTO_IP = 0,    /* Dummy protocol for TCP.  */
  30.     IPPROTO_ICMP = 1,    /* Internet Control Message Protocol.  */
  31.     IPPROTO_GGP = 2,    /* Gateway Protocol (deprecated).  */
  32.     IPPROTO_TCP = 6,    /* Transmission Control Protocol.  */
  33.     IPPROTO_EGP = 8,    /* Exterior Gateway Protocol.  */
  34.     IPPROTO_PUP = 12,    /* PUP protocol.  */
  35.     IPPROTO_UDP = 17,    /* User Datagram Protocol.  */
  36.     IPPROTO_IDP = 22,    /* XNS IDP protocol.  */
  37.  
  38.     IPPROTO_RAW = 255,    /* Raw IP packets.  */
  39.     IPPROTO_MAX,
  40.   };
  41.  
  42. /* Standard well-known ports.  */
  43. enum
  44.   {
  45.     IPPORT_ECHO = 7,        /* Echo service.  */
  46.     IPPORT_DISCARD = 9,        /* Discard transmissions service.  */
  47.     IPPORT_SYSTAT = 11,        /* System status service.  */
  48.     IPPORT_DAYTIME = 13,    /* Time of day service.  */
  49.     IPPORT_NETSTAT = 15,    /* Network status service.  */
  50.     IPPORT_FTP = 21,        /* File Transfer Protocol.  */
  51.     IPPORT_TELNET = 23,        /* Telnet protocol.  */
  52.     IPPORT_SMTP = 25,        /* Simple Mail Transfer Protocol.  */
  53.     IPPORT_TIMESERVER = 37,    /* Timeserver service.  */
  54.     IPPORT_NAMESERVER = 42,    /* Domain Name Service.  */
  55.     IPPROT_WHOIS = 43,        /* Internet Whois service.  */
  56.     IPPORT_MTP = 57,
  57.  
  58.     IPPORT_TFTP = 69,        /* Trivial File Transfer Protocol.  */
  59.     IPPORT_RJE = 77,
  60.     IPPORT_FINGER = 79,        /* Finger service.  */
  61.     IPPORT_TTYLINK = 87,
  62.     IPPORT_SUPDUP = 95,        /* SUPDUP protocol.  */
  63.  
  64.  
  65.     IPPORT_EXECSERVER = 512,    /* execd service.  */
  66.     IPPORT_LOGINSERVER = 513,    /* rlogind service.  */
  67.     IPPORT_CMDSERVER = 514,
  68.     IPPORT_EFSSERVER = 520,
  69.  
  70.     /* UDP ports.  */
  71.     IPPORT_BIFFUDP = 512,
  72.     IPPORT_WHOSERVER = 513,
  73.     IPPORT_ROUTESERVER = 520,
  74.  
  75.     /* Ports less than this value are reserved for privileged processes.  */
  76.     IPPORT_RESERVED = 1024,
  77.  
  78.     /* Ports greater this value are reserved for (non-privileged) servers.  */
  79.     IPPORT_USERRESERVED = 5000,
  80.   };
  81.  
  82.  
  83. /* Link numbers.  */
  84. #define    IMPLINK_IP        155
  85. #define    IMPLINK_LOWEXPER    156
  86. #define    IMPLINK_HIGHEXPER    158
  87.  
  88.  
  89. /* Internet address.  */
  90. struct in_addr
  91.   {
  92.     unsigned long int s_addr;
  93.   };
  94.  
  95.  
  96. /* Definitions of the bits in an Internet address integer.
  97.  
  98.    On subnets, host and network parts are found according to
  99.    the subnet mask, not these masks.  */
  100.  
  101. #define    IN_CLASSA(a)        ((((long int) (a)) & 0x80000000) == 0)
  102. #define    IN_CLASSA_NET        0xff000000
  103. #define    IN_CLASSA_NSHIFT    24
  104. #define    IN_CLASSA_HOST        (0xffffffff & ~IN_CLASSA_NET)
  105. #define    IN_CLASSA_MAX        128
  106.  
  107. #define    IN_CLASSB(a)        ((((long int) (a)) & 0xc0000000) == 0x80000000)
  108. #define    IN_CLASSB_NET        0xffff0000
  109. #define    IN_CLASSB_NSHIFT    16
  110. #define    IN_CLASSB_HOST        (0xffffffff & ~IN_CLASSB_NET)
  111. #define    IN_CLASSB_MAX        65536
  112.  
  113. #define    IN_CLASSC(a)        ((((long int) (a)) & 0xc0000000) == 0xc0000000)
  114. #define    IN_CLASSC_NET        0xffffff00
  115. #define    IN_CLASSC_NSHIFT    8
  116. #define    IN_CLASSC_HOST        (0xffffffff & ~IN_CLASSC_NET)
  117.  
  118. #define    IN_CLASSD(a)        ((((long int) (a)) & 0xf0000000) = 0xe0000000)
  119. #define    IN_MULTICAST(a)        IN_CLASSD(a)
  120.  
  121. #define    IN_EXPERIMENTAL(a)    ((((long int) (a)) & 0xe0000000) = 0xe0000000)
  122. #define    IN_BADCLASS(a)        ((((long int) (a)) & 0xf0000000) = 0xf0000000)
  123.  
  124. /* Address to accept any incoming messages.  */
  125. #define    INADDR_ANY        ((unsigned long int) 0x00000000)
  126. /* Address to send to all hosts.  */
  127. #define    INADDR_BROADCAST    ((unsigned long int) 0xffffffff)
  128. /* Address indicating an error return.  */
  129. #define    INADDR_NONE        0xffffffff
  130.  
  131. /* Network number for local host loopback.  */
  132. #define    IN_LOOPBACKNET    127
  133. /* Address to loopback in software to local host.  */
  134. #ifndef INADDR_LOOPBACK
  135. #define    INADDR_LOOPBACK    0x7f000001    /* Internet address 127.0.0.1.  */
  136. #endif
  137.  
  138.  
  139. /* Structure describing an Internet socket address.  */
  140. struct sockaddr_in
  141.   {
  142.     short int sin_family;        /* Address family.  */
  143.     unsigned short int sin_port;    /* Port number.  */
  144.     struct in_addr sin_addr;        /* Internet address.  */
  145.  
  146.     /* Pad to size of `struct sockaddr'.  */
  147.     unsigned char sin_zero[sizeof(struct sockaddr) -
  148.                sizeof(short int) -
  149.                sizeof(unsigned short int) -
  150.                sizeof(struct in_addr)];
  151.   };
  152.  
  153.  
  154. /* Options for use with `getsockopt' and `setsockopt' at the IP level.
  155.    The first word in the comment at the right is the data type used;
  156.    "bool" means a boolean value stored in an `int'.  */
  157. #define    IP_OPTIONS    1    /* ip_opts; IP per-packet options.  */
  158. #define    IP_HDRINCL    2    /* int; Header is included with data.  */
  159. #define    IP_TOS        3    /* int; IP type of service and precedence.  */
  160. #define    IP_TTL        4    /* int; IP time to live.  */
  161. #define    IP_RECVOPTS    5    /* bool; Receive all IP options w/datagram.  */
  162. #define    IP_RECVRETOPTS    6    /* bool; Receive IP options for response.  */
  163. #define    IP_RECVDSTADDR    7    /* bool; Receive IP dst addr w/datagram.  */
  164. #define    IP_RETOPTS    8    /* ip_opts; Set/get IP per-packet options.  */
  165.  
  166. /* Structure used to describe IP options for IP_OPTIONS and IP_RETOPTS.
  167.    The `ip_dst' field is used for the first-hop gateway when using a
  168.    source route (this gets put into the header proper).  */
  169. struct ip_opts 
  170.   {
  171.     struct in_addr ip_dst;    /* First hop; zero without source route.  */
  172.     char ip_opts[40];        /* Actually variable in size.  */
  173.   };
  174.  
  175.  
  176. /* Functions to convert between host and network byte order.  */
  177.  
  178. extern unsigned long int ntohl __P ((unsigned long int));
  179. extern unsigned short int ntohs __P ((unsigned short int));
  180. extern unsigned long int htonl __P ((unsigned long int));
  181. extern unsigned short int htons __P ((unsigned short int));
  182.  
  183. #include <endian.h>
  184.  
  185. #if __BYTE_ORDER == __BIG_ENDIAN
  186. /* The host byte order is the same as network byte order,
  187.    so these functions are all just identity.  */
  188. #define    ntohl(x)    (x)
  189. #define    ntohs(x)    (x)
  190. #define    htonl(x)    (x)
  191. #define    htons(x)    (x)
  192. #endif
  193.  
  194. #endif    /* netinet/in.h */
  195.